package ee.ut.maxorato_macobo.oop.mud.items;

import java.util.Scanner;

import ee.ut.maxorato_macobo.oop.mud.game.DataParser;
import ee.ut.maxorato_macobo.oop.mud.game.GameUtils;

public class ItemArmourTemplate extends ItemTemplate {
	private String wearLocation;
	
	private int pierceDefBonus;
	private int bashDefBonus;
	private int slashDefBonus;
	private int magicDefBonus;
	
	public ItemArmourTemplate(String newUniqueName, String newItemName, String newItemLongName, String newItemDescription) {
		super(newUniqueName, newItemName, newItemLongName, newItemDescription);
		
		wearLocation = "body";
		
		pierceDefBonus = 0;
		bashDefBonus = 0;
		slashDefBonus = 0;
		magicDefBonus = 0;
	}
	
	@Override
	public Class<? extends ItemBase> getItemClass() {
		return ItemArmour.class;
	}
	
	public String getItemType() {
		return "armour";
	}
	
	public void parseExtraSection(Scanner parser) {
		while(parser.hasNextLine()) {
			String[] parts = parser.nextLine().trim().split(" ", 2);
			
			if(parts[0].equals("location")) {
				wearLocation = parts[1];
			}
			else if(parts[0].equals("def_pierce")) {
				pierceDefBonus = GameUtils.properIntParser(parts[1]);
			}
			else if(parts[0].equals("def_bash")) {
				bashDefBonus = GameUtils.properIntParser(parts[1]);
			}
			else if(parts[0].equals("def_slash")) {
				slashDefBonus = GameUtils.properIntParser(parts[1]);
			}
			else if(parts[0].equals("def_magic")) {
				magicDefBonus = GameUtils.properIntParser(parts[1]);
			}
			else if(parts[0].equals("sub")) {
				DataParser.parseDummy(parser);
			}
			else if(parts[0].equals("end")) {
				break;
			}
		}
	}
	
	public String getWearLocation() {
		return wearLocation;
	}
	
	public int getPierceDefBonus() {
		return pierceDefBonus;
	}
	
	public int getBashDefBonus() {
		return bashDefBonus;
	}
	
	public int getSlashDefBonus() {
		return slashDefBonus;
	}

	public int getMagicDefBonus() {
		return magicDefBonus;
	}
}
